Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update browser URL hash when user presses play button #129

Merged
merged 3 commits into from
May 7, 2024
Merged

Conversation

wch
Copy link
Collaborator

@wch wch commented May 2, 2024

This closes #128. When the user presses the play button, it will automatically update the URL hash.

The encoding is done in a web worker, so it will not block the main thread.

A few remaining tasks:

  • Don't auto-update the if files are very large -- need to figure out how to indicate to user in those cases that they should click the share button.
  • Only update the URL if shinylive is in full-page mode on the examples/ or editor/ URL. Don't update if a shinylive app is embedded in another web page, or if someone is editing an app that they've created a static deployment for.
  • Maybe don't auto-update if the code is loaded from a gist? Not sure what the behavior should be for this case.
  • Only update the URL if the code has been changed (this might not be necessary, though).

@gadenbuie
Copy link
Contributor

  • need to figure out how to indicate to user in those cases that they should click the share button.

Maybe a toast message that says something like "Auto-updating the app link is disabled. Please use the share button."?

  • Maybe don't auto-update if the code is loaded from a gist? Not sure what the behavior should be for this case.

Can gist and code coexist in the URL? I think the expectation is that copying the current URL will give you a link to the app you're editing right then. So to me it makes sense that if you open a gist, update the code and then copy the URL, that URL would restore the edited app.

Keeping the gist provenance seems reasonable so you could delete code=... to reset, but if they're mutually exclusive then I think it's okay to drop gist from the URL.

@wch
Copy link
Collaborator Author

wch commented May 7, 2024

  • need to figure out how to indicate to user in those cases that they should click the share button.

Maybe a toast message that says something like "Auto-updating the app link is disabled. Please use the share button."?

That sounds reasonable -- I did think about that earlier and thought it would be too intrusive, but now that I think about it again, it would only happen in rare cases anyway.

  • Maybe don't auto-update if the code is loaded from a gist? Not sure what the behavior should be for this case.

Can gist and code coexist in the URL? I think the expectation is that copying the current URL will give you a link to the app you're editing right then. So to me it makes sense that if you open a gist, update the code and then copy the URL, that URL would restore the edited app.

Keeping the gist provenance seems reasonable so you could delete code=... to reset, but if they're mutually exclusive then I think it's okay to drop gist from the URL.

gist and code can't coexist, so I suppose it does make sense to replace the gist= with code= if they re-run the app. Ideally it would only be replaced if the user actually modifies the files, and I'll look into making it work that way.

@wch wch marked this pull request as ready for review May 7, 2024 22:43
@wch wch merged commit b8911ae into main May 7, 2024
2 checks passed
@wch wch deleted the update-url branch May 7, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Update URL for current app when running
2 participants